<div id="description">This tests insertion before/after links.  Text should always be inserted at the start or end of a link should be inserted outside of it.</div>
<div id="edit" contenteditable="true"><a id="link" href="http://www.google.com/">this should</a> <a href="http://www.google.com/">this should</a></div>

<script>

if (window.testRunner)
    testRunner.dumpAsText();
    
var edit = document.getElementById("edit");
var sel = window.getSelection();

sel.collapse(edit, 0);

document.execCommand("InsertText", false, "this text should not be in a link");
sel.modify("move", "forward", "word");
sel.modify("move", "forward", "word");

document.execCommand("InsertText", false, "this should not");

sel.modify("move", "forward", "paragraphBoundary");

document.execCommand("InsertText", false, "this should not");

if (window.testRunner)
    document.body.innerText = document.getElementById("description").innerText + "\n\n" + edit.innerHTML;
</script>
